<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="utf-8"%>
<%@ include file="/common/init.jsp"%>
<html>
<head>
<title>澳斯浪廷会员平台</title>
<script type="text/javascript" src="<c:url value='/resources/js/jquery-1.10.2.min.js'/>"></script>
<script type="text/javascript" src="<c:url value='/resources/js/organictabs.jquery.js'/>"></script>
<link type="text/css" href="<c:url value='/resources/css/lrtk.css'/>" rel="stylesheet" />
<script type="text/javascript" src="<c:url value='/resources/js/validate.js'/>"></script>
<script type="text/javascript" src="<c:url value='/resources/js/MathUtil.js'/>"></script>
<script type="text/javascript" src="<c:url value='/resources/js/mask.js'/>"></script>
<script type="text/javascript">
$(function() {
	// 调用插件
	$("#example-one").organicTabs();
	$("#example-two").organicTabs({
		"speed": 100
	});
});
//卖出
function doSale(){
	$.ajaxSetup({cache:false});
	var checkFlg = true;
	checkFlg = checkFlg && validateEmpty_jquery("卖出", "prizeAmount");
	checkFlg = checkFlg && validateNumber_jquery("卖出 ", "prizeAmount");//要卖出的
	var saleAmount = $("#prizeAmount").val();
	if(dcmSub(saleAmount,500)<0){//小于500
		alert("EP交易的交易金额不能低于500");
		return;
	}
	var amount = $("#bonusMoney").val();//总奖金币
	var epfee = $("#epfee").val();
	var eppayfee = $("#eppayfee").val();
	var fact = dcmAdd(saleAmount,dcmMul(saleAmount,epfee));
	if(fact > amount){
		alert("余额不足，请重写填写数据!");
		return ;
	}
	var val=$('input:radio[name="agree"]:checked').val();
	if(val==null){
		setValidateErrorStyle_jquery($("#agree"));
		alert("请选择用户协议!");
		return false;
	}
	checkFlg = checkFlg && validateEmpty_jquery("验证码","code");
	$.ajax({
		type:'POST',
		url: "${ctx}/userCheck.action",
		data: "code="+$("#code").val(),
        async:false,  // 设置同步方式
        cache:false,
		dataType:"html",
		success: function(data,status){
			if($.trim(data)!=''){
				setValidateErrorStyle_jquery($("#code"));
				alert("验证码输入错误");
				checkFlg = false;
			}
		},
		error: function(data,status,e){
			alert(e.name);
		}
	});
	checkFlg = checkFlg && validateEmpty_jquery("三级密码", "thirdPassword");
	//checkFlg = checkFlg && false;
	$.ajax({
		type:'POST',
		url: "${ctx}/chkTidPwd.action",
		data: "thirdPassword="+$("#thirdPassword").val(),
        async:false,  // 设置同步方式
        cache:false,
		dataType:"html",
		success: function(data,status){
			if($.trim(data)!=''){
				setValidateErrorStyle_jquery($("#thirdPassword"));
				alert(data);
				checkFlg = false;
			}
		},
		error: function(data,status,e){
			alert(e.name);
		}
	});
	if ( !checkFlg ) return;
    if (checkFlg) {
    	//var data = $("#othermember").formSerialize();
    	if(confirm("本次ep交易,加上相应的手续费,共计要冻结咖啡豆"+fact+",您确定要进行交易吗？")){
	    	//document.forms[0].action = "${ctx}/doep.action";
	        //document.forms[0].submit();
    		var data = $("#epsaleForm").serialize();
            $(document).mask("系统处理中，请稍后......");
            jQuery.ajax({
    			url: "${ctx}/doep.action",
    			type: "post",
    			dataType:"html",
    			data:data,
    			async:false,
    			success: function(jsondata){
    				alert(jsondata);
    				window.location.href = "${ctx}/ep.action";
    			},
    			error: function(XMLHttpRequest, textStatus, errorThrown) {
    		    }
    		});
    	}
    }
}

function dobuy(id){
	var credit = $("#credit").val();
	if(credit == '0'){
		alert("您的信用度是0，不能进行ep交易");
		return;
	}
	if(confirm("您确定要进行交易吗？如果您违约，将扣除你相应的信用度")){    
		$(document).mask("系统处理中，请稍后......");
    	window.location.href= "${ctx}/epconfirm.action?id="+id;
	}
}

function frontpage(pageNo){
	window.location.href= "${ctx}/ep.action?pageNo="+pageNo;
}

function nextpage(pageNo){
	window.location.href= "${ctx}/ep.action?pageNo="+pageNo;
}
</script>
<link href="<c:url value='/resources/css/css.css'/>" type="text/css" rel="stylesheet" />
</head>
<body>
<div class="main">
<div class="width_l">
    <iframe src="menu.action" frameborder="0" width="250" height="100%" class="menu"></iframe>
</div>    
    <div class="right">
    <div class="width_r">
        <div class="menu_r">
            <ul>
                <li><a href="index.action">首页</a></li>
                <li><a href="information.action">消息</a></li>
                <li><a href="notice.action">公告中心</a></li>
                <li><a href="news.action">新闻中心</a></li>
                <li><a href="inbox.action">收件箱</a></li>
                <li><a href="tomail.action">写邮件</a></li>
                <li><a href="sent.action">已发送</a></li>
                <li><a href="${ctx}/exit.action">安全退出</a></li> 
            </ul>
        </div>
        <div class="ep_top"><img src="<c:url value='/resources/images/top.jpg'/>" /></div>
        <div class="news">
            <div class="ep_title">
              <div class="epjiaoyi">EP交易</div>
                <div class="epmore"><a href="epmore.action">查看个人交易信息</a></div>
            </div>
            <!-- 代码开始 -->
<div id="page-wrap">
	<!-- BEGIN Organic Tabs (Example One) -->
	<div id="example-two">
		
		<ul class="nav">
			<li class="nav-one"><a href="#featured2" class="current">买入</a></li>
			<li class="nav-two"><a href="#core2">卖出</a></li>
			<!-- <li class="nav-two"><a href="epsalepage.action">卖出</a></li> -->
		</ul>
		<input type="hidden" id="credit" value="${user.creditLevel}"/>
		<div class="list-wrap">
           <ul id="featured2">
				<li>
                <table width="840" border="0" cellpadding="0" cellspacing="0" style="border:#dadada 1px solid; background-color:#f0f0f0; margin-left:10px; height:32px; line-height:32px; color:#676767; text-align:center;">
				  <tr>
				    <td width="140">会员ID</td>
				    <td width="130">EP金额</td>
				    <td width="170">银行名称</td>
				    <td width="">省/洲</td>
				    <td width="167">信用星</td>
				    <td width="130">操作</td>
				  </tr>
				</table>
				<table width="840" border="0" cellpadding="0" cellspacing="0" style="text-align:center; color:#676767; margin-left:10px;">
				  <c:forEach var="ep" items="${epList}">
					  <tr>
					    <td class="mr_line" width="140">${ep['user_account']}</td>
					    <td class="mr_line" width="130">${ep['deal_amount']}</td>
					    <td class="mr_line" width="170">${ep['bank_name']}</td>
					    <td class="mr_line" width="">${ep['bank_province']}</td>
					    <td class="mr_line" width="167">
					    	<c:forEach begin="1" end="${ep['credit_level']}">
					    		<img src="<c:url value='/resources/images/zuanshi.png'/>"/>
					    	</c:forEach>
					     </td>
					    <td class="mr_line" width="130" align="center">
					    	<img src="<c:url value='/resources/images/icon_3.jpg'/>" onclick="dobuy('${ep['id']}')"/>
					    </td>
					  </tr>
				  </c:forEach>
				  <tr>
					<td style="text-align:right;" colspan="6">
					<c:choose>
						<c:when test="${pageNo >1}">
							<a href="javascript:void(0);" style="text-decoration: none;">
								<span onclick="frontpage(1)">首页</span>
							</a>&nbsp;
							<a href="javascript:void(0);" style="text-decoration: none;">
								<span onclick="frontpage(${pageNo-1})">上一页</span>
							</a>&nbsp;
						</c:when>
						<c:otherwise>
							首页&nbsp;上一页 &nbsp;
						</c:otherwise>
						</c:choose>
						<c:choose>
							<c:when test="${totalPage > pageNo}">	
								<a href="javascript:void(0);" style="text-decoration: none;">
									<span onclick="nextpage(${pageNo+1})">下一页</span> 
								</a>&nbsp;
								<a href="javascript:void(0);" style="text-decoration: none;">
									<span onclick="nextpage(${totalPage})">末页</span> 
								</a>&nbsp;
							</c:when>
							<c:otherwise>
								下一页&nbsp;末页&nbsp;
							</c:otherwise>
						</c:choose>
					</td>
				</tr>
				</table>
				</li>
				<table width="840" border="0" cellpadding="0" cellspacing="0"
						style="color: #676767; line-height: 40px; margin-left: 10px;">
					<td class="mr_line" colspan="3" align="center"> <span>在您确定交易前，请仔细阅读公告交易准则，如您违约将会扣除相应的信用度.&nbsp;<a href="protocols.action" target="_blank">EP交易《用户协议》</a></span>
				<tr>
			</td>
		</tr>
				</table>
			</ul>
			<ul id="core2" class="hide">
				<s:action name="epsalepage" executeResult="true"></s:action>
			</ul>
		</div>
	</div>
	<!-- END Organic Tabs (Example Two) -->
</div>
<!-- 代码结束 -->
        </div>
        <div class="news_down"><img src="<c:url value='/resources/images/down.jpg'/>" /></div>
    </div>
    </div>
</div>

</body>
</html>